
/**
 *项目效果展示-Part2。
 */

addModule({
	name: "Map Chart",

	config: {
        duration: 1000,

        map_data : [],

        names: [],
    },

	graphic: {
		opt: null
	},	

	/**
     * 本模块的初始化函数
	 */
	init : function() {

        //this.set_background();

        // 调用: 将分镜 (子场景入口函数) 全部加到场景列表中去
		addSceneFunc("Map-scene", this.map_chart, this.name, null);

	},
    /*
    set_background : function() {

        $("div#main").css({"background-image":"url(timg-2.jpg)", "background-size":"700px 700px", "background-position":"center center", "background-repeat":"no-repeat"});

    },
    */
	map_chart : function() {

		var series = [
            {
            	name: this.config.names[0],
	            type: 'scatter',
            	coordinateSystem: 'cartesian2d',
            	symbol:'circle',
            	symbolSize: 50,
            	xAxisIndex: 0,
            	yAxisIndex: 0,
            	color: 'green',
                data:  [
                    this.config.map_data[0]//交职
                ]
            },{
                name: this.config.names[1],
	            type: 'scatter',
            	coordinateSystem: 'cartesian2d',
            	symbol:'circle',
            	symbolSize: 50,
            	xAxisIndex: 0,
            	yAxisIndex: 0,
                data: [
                	this.config.map_data[1] //成信
                ],	
            },{
                name: this.config.names[2],
	            type: 'scatter',
            	coordinateSystem: 'cartesian2d',
            	symbol:'circle',
            	symbolSize: 50,
            	xAxisIndex: 0,
            	yAxisIndex: 0,
            	color:'yellow',
                data: [
                	this.config.map_data[2] //锦城
                ],	
            },{
            	//西华大学
                name: this.config.names[3],
	            type: 'scatter',
            	coordinateSystem: 'cartesian2d',
            	symbol:'circle',
            	symbolSize: 50,
            	xAxisIndex: 0,
            	yAxisIndex: 0,
                data: [
                    this.config.map_data[3] //西华
                ],	
            },{
            	//电子科大
                name: this.config.names[4],
	            type: 'scatter',
            	coordinateSystem: 'cartesian2d',
            	symbol:'circle',
            	symbolSize: 50,
            	xAxisIndex: 0,
            	yAxisIndex: 0,
                data: [
                    this.config.map_data[4] //电科
                ],	
            },{
            	//四川大学
                name: this.config.names[5],
	            type: 'scatter',
            	coordinateSystem: 'cartesian2d',
            	symbol:'circle',
            	symbolSize: 50,
            	xAxisIndex: 0,
            	yAxisIndex: 0,
                data: [
                    this.config.map_data[5]//川大
                ],	
            }
        ];


        
		var option = this.graphic.opt = {
			xAxis: [
        		{gridIndex: 0, min: 0, max: 200 ,show: false},
			],
			yAxis: [
        		{gridIndex: 0, min: 0, max: 200 ,show: false},
			],
			grid: [
        		{
        			x: '7%', 
        			y: '7%', 
        			width: 'auto', 
        			height: 'auto', 
        			show: false
        		}
			],
			visualMap: {
                left: 'left',
                top: 'top',
                dimension: 2,
                min: 50,
                max: 1000,
                itemHeight: 120,
                calculable: true,
                text: ['日搜索量'],
                textGap: 30,
                inRange: {
                    color: ['grey', 'black']
                },
                outOfRange: {
                    color: 'grey'
                },
                orient: 'horizontal'
            },
            legend:{
                left: 'right',
                top: 'top',
                data: this.config.legend_data
            },
			tooltip: {
				padding: 10,
        		backgroundColor: '#222',
        		borderColor: '#777',
        		borderWidth: 1,
                formatter: function(obj) {
                    var value = obj.value;

                    /*
                     *格式：
                     *  8.23
                     *  学校名
                     *  搜索量XX
                     */
                    return '8.23<br />' + value[3] + '<br />搜索量' + value[2];
                }
			},
			series: series
		};

		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);

        

        //结束函数
        addRenderFunc(this.name + "-end",function(){
            myChart.clear();
            //this.remove_background();
            endScene();

        },{
           once : true,
           delay : this.config.duration
        });
		
		
	},
    /*
    remove_background : function() {
        $("div#main").css({"background-image":"", "background-size":"", "background-position":"", "background-repeat":""});
    },
    */
    require : [{
        type : 'image',
        name : 'timg-2.jpg'
    }]

});